package com.zl.learning.object.test;

/**
 * Created by zhaolei on 2017/6/11.
 */
public class NutritionFacts {
    private String name;
    private int age;
    private String nickName;

    public static class Builder{
        private String name;
        private int age = 18;
        private String nickNmae = "zhansan";

        public Builder(String name){
            this.name = name;
        }

        public Builder nickName(String nickNmae){
            this.nickNmae = nickNmae;
            return this;
        }

        public Builder age(int age){
            this.age = age;
            return this;
        }

        public NutritionFacts build(){
            return new NutritionFacts(this);
        }
    }

    @Override
    public String toString() {
        return "NutritionFacts{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", nickName='" + nickName + '\'' +
                '}';
    }

    public NutritionFacts(Builder builder){
        this.name = builder.name;
        this.age = builder.age;
        this.nickName = builder.nickNmae;
    }

    public static void main(String[] args) {
        NutritionFacts nutritionFacts = new NutritionFacts.Builder("aaa").age(11).nickName("lisi").build();
        System.out.println(nutritionFacts.toString());
    }

}
